import * as types from '../action-types'
import {push} from 'connected-react-router'

interface incrementAction {
  type: string
}
interface decrementAction {
  type: string
}
export type Action = incrementAction | decrementAction
export default {
  increment () {
    //  同步
    //  return {type:types.INCREMENT}
    // 异步 redux-thunk
    return function(dispatch,getState){
      setTimeout(function(){
        dispatch({type:types.INCREMENT})
      },1000)
    }
   },
  decrement ():decrementAction {
    return {type:types.DECREMENT}
  },
  goto(){
    // 通过action跳转
    return push('/2')
  }
 }